package com.wanczy.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wanczy.pojo.ShowFavorite;
import com.wanczy.service.ShowFavoriteService;

@Controller
public class ShowFavoriteController {
	 @Autowired
	private ShowFavoriteService showFavoriteService;
	 
	 @RequestMapping("/showFavorite")
	    public String getAllCart(@RequestParam(value="userId") Integer userId,Map<String,Object> map) {
	    	System.out.println(userId);
	    	List<ShowFavorite> list =  showFavoriteService.getShowFavorite(userId);
	    	
	    	map.put("ShowFavorite", list);
			return "/cart/showfavorite";
	    	
	    }
	 //public int getDelfavorite(Integer favoriteId)
	  //删除商品
	    @ResponseBody
	    @RequestMapping("/deletefavorite")
	    public List<Integer> deleteCart(@RequestParam("favoriteId") Integer favoriteId){
	     
	            int favorite = showFavoriteService.getDelfavorite(favoriteId);
	            List<Integer> list = new ArrayList<Integer>();
	            list.add(favorite);
	          //  System.out.println(list);
	            return list;
	    }
}
